"""Address database schema."""

__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id: schema.py,v 1.2 2002/03/07 16:22:34 pobrien Exp $"
__revision__ = "$Revision: 1.2 $"[11:-2]


from bdoz.database import EntityManager
from bdoz.entity import Entity
from bdoz.field import UnicodeField


class OutlookField(UnicodeField):
    _required = 0
    _convert = 1


class NameField(OutlookField):
    _label = 'Person Name'
    _default = ''
    _min = None
    _max = None


class Address(Entity):
    """Address class."""

    _fields = {
              'Name': NameField,
              'Company': OutlookField,
              'Street': OutlookField,
              'City': OutlookField,
              'State': OutlookField,
              'Zip': OutlookField,
              'Notes': OutlookField,
              'Phone1': OutlookField,
              'Phone2': OutlookField,
              'Phone3': OutlookField,
              'Phone4': OutlookField,
              }

    def __init__(self, Name='', Company='', Street='',
                 City='', State='', Zip='', Notes='',
                 Phone1='', Phone2='', Phone3='', Phone4=''):
        """Create an Address instance."""
        values = {
                  'Name': Name,
                  'Company': Company,
                  'Street': Street,
                  'City': City,
                  'State': State,
                  'Zip': Zip,
                  'Notes': Notes,
                  'Phone1': Phone1,
                  'Phone2': Phone2,
                  'Phone3': Phone3,
                  'Phone4': Phone4,
                  }
        Entity.__init__(self, fieldValues=values)


class Database(EntityManager):
    """Database manager class."""

    EntityClasses = [Address]

